<template>
  <el-row :gutter="40" class="panel-group">
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel">
        <div class="card-panel-description">
            <div class="card-panel-text">日交易量</div>
            <div class="card-panel-textDate">成功:<count-to :start-val="0" :end-val="Number(count.dayCountS)" :duration="3000" class="card-panel-numData"/></div>
            <div class="card-panel-textDate">失败:<count-to :start-val="0" :end-val="Number(count.dayCountF)" :duration="3000" class="card-panel-numData"/></div>
            <div class="card-panel-textDate">挂起:<count-to :start-val="0" :end-val="Number(count.dayCountP)" :duration="3000" class="card-panel-numData"/></div>
        </div>
        <div class="card-panel-icon-wrapper icon-shopping">
          <svg-icon icon-class="skill" class-name="card-panel-icon" />
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel" >
        <div class="card-panel-description">
          <div class="card-panel-text">日交易金额</div>
          <div class="card-panel-textDate">成功:<count-to :start-val="0" :end-val="Number(count.dayAmountS)" :duration="3000" class="card-panel-numData"/></div>
          <div class="card-panel-textDate">失败:<count-to :start-val="0" :end-val="Number(count.dayAmountF)" :duration="3000" class="card-panel-numData"/></div>
          <div class="card-panel-textDate">挂起:<count-to :start-val="0" :end-val="Number(count.dayAmountP)" :duration="3000" class="card-panel-numData"/></div>
        </div>
        <div class="card-panel-icon-wrapper icon-message">
          <svg-icon icon-class="list" class-name="card-panel-icon" />
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel">
        <div class="card-panel-icon-wrapper icon-money">
          <svg-icon icon-class="skill" class-name="card-panel-icon" />
        </div>
      <div class="card-panel-description">
        <div class="card-panel-text">周交易量</div>
        <div class="card-panel-textDate">成功:<count-to :start-val="0" :end-val="Number(count.weekCountS)" :duration="3000" class="card-panel-numData"/></div>
        <div class="card-panel-textDate">失败:<count-to :start-val="0" :end-val="Number(count.weekCountF)" :duration="3000" class="card-panel-numData"/></div>
        <div class="card-panel-textDate">挂起:<count-to :start-val="0" :end-val="Number(count.weekCountP)" :duration="3000" class="card-panel-numData"/></div>
      </div>

      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel">
        <div class="card-panel-description">
          <div class="card-panel-text">周交易金额</div>
          <div class="card-panel-textDate">成功:<count-to :start-val="0" :end-val="Number(count.weekAmountS)" :duration="3000" class="card-panel-numData"/></div>
          <div class="card-panel-textDate">失败:<count-to :start-val="0" :end-val="Number(count.weekAmountF)" :duration="3000" class="card-panel-numData"/></div>
          <div class="card-panel-textDate">挂起:<count-to :start-val="0" :end-val="Number(count.weekAmountP)" :duration="3000" class="card-panel-numData"/></div>
        </div>
        <div class="card-panel-icon-wrapper icon-shopping">
          <svg-icon icon-class="list" class-name="card-panel-icon" />
        </div>
      </div>
    </el-col>
  </el-row>
</template>

<script>
import CountTo from 'vue-count-to'
import { get } from '@/api/monitor/visits'
export default {
  components: {
    CountTo
  },
  data(){
    return {
      count: { dayCountS: '0',dayAmountS: '0',dayCountF: '0',dayAmountF: '0',dayCountP: '0',dayAmountP: '0',
        weekCountS: '0',weekAmountS: '0',weekCountF: '0',weekAmountF: '0',weekCountP: '0',weekAmountP: '0'}
    }

  },
  mounted(){
    get().then(res => {
      this.count.dayCountS =isNaN(res.dayCountS)?'0':res.dayCountS
      this.count.dayAmountS =isNaN(res.dayAmountS)?'0':res.dayAmountS
      this.count.dayCountF =isNaN(res.dayCountF)?'0':res.dayCountF
      this.count.dayAmountF =isNaN(res.dayAmountF)?'0':res.dayAmountF
      this.count.dayCountP =isNaN(res.dayCountP)?'0':res.dayCountP
      this.count.dayAmountP =isNaN(res.dayAmountP)?'0':res.dayAmountP
      this.count.weekCountS =isNaN(res.weekCountS)?'0':res.weekCountS
      this.count.weekAmountS =isNaN(res.weekAmountS)?'0':res.weekAmountS
      this.count.weekCountF =isNaN(res.weekCountF)?'0':res.weekCountF
      this.count.weekAmountF =isNaN(res.weekAmountF)?'0':res.weekAmountF
      this.count.weekCountP =isNaN(res.weekCountP)?'0':res.weekCountP
      this.count.weekAmountP =isNaN(res.weekAmountP)?'0':res.weekAmountP
    })
  }
}
</script>

<style lang="scss" scoped>
.panel-group {
  margin-top: 18px;

  .card-panel-col {
    margin-bottom: 32px;
  }

  .card-panel {
    height: 108px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
    border-color: rgba(0, 0, 0, .05);

    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }

      .icon-people {
        background: #40c9c6;
      }

      .icon-message {
        background: #36a3f7;
      }

      .icon-money {
        background: #f4516c;
      }

      .icon-shopping {
        background: #34bfa3
      }
    }

    .icon-people {
      color: #40c9c6;
    }

    .icon-message {
      color: #36a3f7;
    }

    .icon-money {
      color: #f4516c;
    }

    .icon-shopping {
      color: #34bfa3
    }

    .card-panel-icon-wrapper {
      float: right;
      margin: 14px 0 0 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

    .card-panel-icon {
      float: right;
      font-size: 48px;
    }

    .card-panel-description {
      float: left;
      font-weight: bold;
      margin: 26px;
      margin-left: 0px;

      .card-panel-text {
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 16px;
        margin-bottom: 12px;
      }

      .card-panel-num {
        font-size: 20px;
      }

      .card-panel-textDate{
        line-height: 8px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 12px;
        margin-bottom: 10px;
        text-indent: 10px;
        margin-left: 10px;
      }
      .card-panel-numData{
        font-size: 15px;
      }
    }
  }
}

@media (max-width:550px) {
  .card-panel-description {
    display: none;
  }

  .card-panel-icon-wrapper {
    float: none !important;
    width: 100%;
    height: 100%;
    margin: 0 !important;

    .svg-icon {
      display: block;
      margin: 14px auto !important;
      float: none !important;
    }
  }
}
</style>
